package com.lujieni.moon.config;

import com.lujieni.moon.properties.JwtProperties;
import com.lujieni.moon.utils.JWTUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author
 * @Title: JwtUtilsConfiguration
 * @Description:
 * @date 2022/11/23 4:34 下午
 */
@Configuration
@ConditionalOnProperty(name = "filter.jwt.verify.global.enabled", matchIfMissing = false)
@EnableConfigurationProperties(JwtProperties.class)
public class JwtUtilsConfiguration {

    @Autowired
    private JwtProperties jwtProperties;

    @Bean
    public JWTUtils jwtUtils(){
        JWTUtils jwtUtils = new JWTUtils();
        jwtUtils.setPublicKey(jwtProperties.getPublickKey());
        jwtUtils.setPrivateKey(jwtProperties.getPrivateKey());
        return jwtUtils;
    }

}
